package com.party.core.model.mall;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 订单业务状态
 */
public enum MallOrderDetailStatus {
    STATUS_NOT_PAY(2, "待付款"), // 创建订单默认

    STATUS_NOT_SHIPMENT(3, "待发货"), // 支付完成后

    STATUS_HAVE_SHIPMENT(4, "已发货"), // 填写物流信息后

    STATUS_REFUND_ING(6, "退款中"), //  用户申请退款后

    STATUS_REFUND_SUCCESS(9, "退款成功"), // 管理员同意退款后
    
    STATUS_REFUND_REJECT(5, "退款拒绝"), //管理员拒绝退款后

    STATUS_NOT_EVALUATE(10, "待评价"), // 用户确认收货后

    STATUS_COMPLETE(7, "已完成"), // 用户评价完成后

    STATUS_CLOSED(8, "已关闭"); // 用户取消订单后/用户确认收到退款后

    //状态码
    private Integer code;

    //状态值
    private String value;

    MallOrderDetailStatus(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    /**
     * 根据状态码获取状态值
     *
     * @param code 状态码
     * @return 状态值
     */
    public static String getValue(Integer code) {
        for (MallOrderDetailStatus orderType : MallOrderDetailStatus.values()) {
            if (orderType.getCode().equals(code)) {
                return orderType.getValue();
            }
        }
        return null;
    }


    /**
     * 枚举类型转换为map
     *
     * @return 转换后的map
     */
    public static Map<Integer, String> convertMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (MallOrderDetailStatus orderType : MallOrderDetailStatus.values()) {
            map.put(orderType.getCode(), orderType.getValue());
        }
        return map;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
